package cn.com.fuhuitong.main.home.mode

import cn.com.fuhuitong.http.BaseAbstractManager
import cn.com.fuhuitong.http.BaseResponse
import cn.com.fuhuitong.http.ResponseSubscribeListener
import cn.com.fuhuitong.http.SubscribeListener
import cn.com.fuhuitong.main.home.entity.*
import io.reactivex.Observable
import io.reactivex.disposables.Disposable
import retrofit2.http.Field
import retrofit2.http.Header
import retrofit2.http.Query

class HomeManager : BaseAbstractManager<HomeApi>(HomeApi::class.java) {

    /**
     * 获取首页数据
     */
    fun homeIndex(listener: SubscribeListener<HomeResponse>): Disposable {
        val homeIndex: Observable<HomeResponse> = apiService.homeIndex()
        return subscribe(homeIndex, ResponseSubscribeListener(listener))
    }


    /**
     * 获取首页数据
     */
    fun homeGoods(
        page: String, limit: String,
        listener: SubscribeListener<HomeGoodsResponse>
    ): Disposable {
        val homeGoods: Observable<HomeGoodsResponse> = apiService.homeGoods(page, limit)
        return subscribe(homeGoods, ResponseSubscribeListener(listener))
    }

    /**
     * 获取首页数据
     */
    fun indexGetTwoHomeGoods(
        token: String, id: String, listener: SubscribeListener<CategoryTwoResponse>
    ): Disposable {
        val homeGoods: Observable<CategoryTwoResponse> = apiService.indexGetTwoHomeGoods(token, id)
        return subscribe(homeGoods, ResponseSubscribeListener(listener))
    }

    /**
     * 获取公益慈善列表
     */
    fun charityIndex(
        token: String, page: String, limit: String, type: String,
        listener: SubscribeListener<CharityListResponse>
    ): Disposable {
        val charityIndex: Observable<CharityListResponse> =
            apiService.charityIndex(token, page, limit, type)
        return subscribe(charityIndex, ResponseSubscribeListener(listener))
    }

    /**
     * 获取公益慈善详情
     */
    fun charityDetails(
        token: String, charityId: String,
        listener: SubscribeListener<CharityDetailsResponse>
    ): Disposable {
        val charityDetails: Observable<CharityDetailsResponse> =
            apiService.charityDetails(token, charityId)
        return subscribe(charityDetails, ResponseSubscribeListener(listener))
    }

    /**
     * 获取公益慈善报名
     */
    fun charitySignUp(
        signUpEntity: CharitySignUpEntity, listener: SubscribeListener<BaseResponse>
    ): Disposable {
        val charitySignUp: Observable<BaseResponse> =
            apiService.charitySignUp(signUpEntity)
        return subscribe(charitySignUp, ResponseSubscribeListener(listener))
    }

    /**
     * 获取改善案例列表
     * */
    fun caseIndex(
        type: String, page: String, limit: String,
        listener: SubscribeListener<CaseListResponse>
    ): Disposable {
        val caseIndex: Observable<CaseListResponse> =
            apiService.caseIndex(type, page, limit)
        return subscribe(caseIndex, ResponseSubscribeListener(listener))
    }

    /**
     * 获取改善案例列表
     * */
    fun caseIndex(
        homeIconId: String, twoHomeIconId: String, page: String, limit: String,
        listener: SubscribeListener<CaseListResponse>
    ): Disposable {
        val caseIndex: Observable<CaseListResponse> =
            apiService.caseIndex(homeIconId, twoHomeIconId, page, limit)
        return subscribe(caseIndex, ResponseSubscribeListener(listener))
    }

    /**
     * 获取改善案例列表
     * */
    fun caseChairIndex(
        type: String, page: String, limit: String,
        listener: SubscribeListener<CaseListResponse>
    ): Disposable {
        val caseIndex: Observable<CaseListResponse> =
            apiService.caseChairIndex(type, page, limit)
        return subscribe(caseIndex, ResponseSubscribeListener(listener))
    }

    /**
     * 会员列表
     * */
    fun memberList(
        token: String, listener: SubscribeListener<MemberResponse>
    ): Disposable {
        val memberList: Observable<MemberResponse> = apiService.memberList(token)
        return subscribe(memberList, ResponseSubscribeListener(listener))
    }

    /**
     * 获取指定会员
     * */
    fun memberItem(
        token: String, id: String,
        listener: SubscribeListener<MemberResponse>
    ): Disposable {
        val charityIndex: Observable<MemberResponse> =
            apiService.memberItem(token, id)
        return subscribe(charityIndex, ResponseSubscribeListener(listener))
    }

    /**
     * 获取旗舰店列表
     * */
    fun flagshipIndex(
        search: String, lat: String, lng: String, page: String, limit: String,
        listener: SubscribeListener<FlagshipListResponse>
    ): Disposable {
        val flagshipIndex: Observable<FlagshipListResponse> =
            apiService.flagshipIndex(search, lat, lng, page, limit)
        return subscribe(flagshipIndex, ResponseSubscribeListener(listener))
    }

    /**
     * 获取签到列表
     * */
    fun signInLog(
        token: String, listener: SubscribeListener<SignInListResponse>
    ): Disposable {
        val signInLog: Observable<SignInListResponse> =
            apiService.signInLog(token)
        return subscribe(signInLog, ResponseSubscribeListener(listener))
    }

    /**
     * 用户签到
     * */
    fun signInUser(
        token: String, listener: SubscribeListener<BaseResponse>
    ): Disposable {
        val signInUser: Observable<BaseResponse> =
            apiService.signInUser(token)
        return subscribe(signInUser, ResponseSubscribeListener(listener))
    }

    /**
     * 快报列表
     * */
    fun expressNewsList(
        page: String, limit: String, listener: SubscribeListener<BulletinListResponse>
    ): Disposable {
        val expressNewsList: Observable<BulletinListResponse> =
            apiService.expressNewsList(page, limit)
        return subscribe(expressNewsList, ResponseSubscribeListener(listener))
    }

    /**
     * 公益交流会报名
     * */
    fun enrollWelfare(
        token: String,
        name: String,
        sex: String,
        year: String,
        address: String,
        id_num: String,
        mobile: String,
        objective: String, listener: SubscribeListener<BaseResponse>
    ): Disposable {
        val baseResponse: Observable<BaseResponse> =
            apiService.enrollWelfare(token, name, sex, year, address, id_num, mobile, objective)
        return subscribe(baseResponse, ResponseSubscribeListener(listener))
    }

    /**
     * 申请调理报名
     * */
    fun enrollRecuperate(
        token: String,
        name: String,
        sex: String,
        year: String,
        address: String,
        id_num: String,
        mobile: String,
        disease: String,
        treatment_record: String,
        heard_record: String,
        existing_symptoms: String,
        physical_condition: String,
        disclaimer: String,
        conditioning: String,
        listener: SubscribeListener<BaseResponse>
    ): Disposable {
        val baseResponse: Observable<BaseResponse> =
            apiService.enrollRecuperate(
                token,
                name,
                sex,
                year,
                address,
                id_num,
                mobile,
                disease,
                treatment_record,
                heard_record,
                existing_symptoms,
                physical_condition,
                disclaimer,
                conditioning
            )
        return subscribe(baseResponse, ResponseSubscribeListener(listener))
    }

    /**
     * 老人申请入驻
     * */
    fun enrollElderly(
        token: String,
        name: String,
        sex: String,
        year: String,
        address: String,
        id_num: String,
        mobile: String,
        listener: SubscribeListener<BaseResponse>
    ): Disposable {
        val baseResponse: Observable<BaseResponse> =
            apiService.enrollElderly(token, name, sex, year, address, id_num, mobile)
        return subscribe(baseResponse, ResponseSubscribeListener(listener))
    }

}